/*
 * @Descripttion: 
 * @version: 
 * @Author: mmzhang
 * @Date: 2021-07-23 11:03:01
 * @LastEditTime: 2022-05-18 18:50:06
 */
import table from '@/components/dt/table/render.js'

let _this = null;

const sendThis = (vm) => {
  _this = vm;
};
export default {
  sendThis,
  columns: [{
    title: '区域/子公司',
    minWidth: 250,
    field: 'orgEndName',
    fixed: 'left',
    treeNode: true,
    slots: {
      default: (params, h) => {
        return table.cell.text(h, {
          value: params.row.orgEndName
        })
      }
    }
  },
  {
    title: '开发商简称',
    field: 'developerAbbreviation',
    minWidth: 200,
    slots: {
      default: (params, h) => {
        return [h('div', params.row.developerAbbreviation)]
      }
    }
  },
  {
    title: '来人',
    field: 'comer',
    minWidth: 180,
    cell:{
      value:(info)=> info.comer,
      text:{
        type: 'number',
        fixed: 0
      }
    }
  },
  {
    title: '认购',
    field: 'subscribe',
    minWidth: 180,
    slots: {
      default: (params, h) => {
        if (params.row.subscribe != '0') {
          return table.cell.btn(_this, h, {
            title: params.row.subscribe,
            event: 'linkSubSummaryFun',
            data: [params.row, 0],
            type:'number',
            fixed: 0
          })
        } else {
          return [h('div', params.row.subscribe)]
        }
      }
    }
  },
  {
    title: '认购金额（元）',
    field: 'subscribeAmount',
    minWidth: 150,
    slots: {
      default: (params, h) => {
        if (params.row.subscribe != '0') {
          return table.cell.btn(_this, h, {
            title: params.row.subscribeAmount,
            event: 'linkSubSummaryFun',
            data: [params.row, 0],
            type:'number'
          })
        } else {
          return [h('div', _this.$tool.formatterMoney(params.row.subscribeAmount))]
        }
      }
    }
  },
  {
    title: '认购率（%）',
    field: 'subscribeRate',
    minWidth: 130,
    slots: {
      default: (params, h) => {
        return [h('div', ((params.row.subscribeRate * 10000) / 100).toFixed(2))]
      }
    }
  },
  {
    title: '退购',
    field: 'repurchase',
    minWidth: 180,
    slots: {
      default: (params, h) => {
        if (params.row.repurchase != '0') {
          return table.cell.btn(_this, h, {
            title: params.row.repurchase,
            event: 'linkSubSummaryFun',
            data: [params.row, 1],
            type:'number',
            fixed: 0
          })
        } else {
          return [h('div', params.row.repurchase)]
        }
      }
    }
  },
  {
    title: '退购金额（元）',
    field: 'repurchaseAmount',
    minWidth: 150,
    slots: {
      default: (params, h) => {
        if (params.row.repurchase != '0') {
          return table.cell.btn(_this, h, {
            title: params.row.repurchaseAmount,
            event: 'linkSubSummaryFun',
            data: [params.row, 1],
            type:'number'
          })
        } else {
          return [h('div', _this.$tool.formatterMoney(params.row.repurchaseAmount))]
        }
      }
    }
  },
  {
    title: '退购率（%）',
    field: 'repurchaseRate',
    minWidth: 130,
    slots: {
      default: (params, h) => {
        return [h('div', ((params.row.repurchaseRate * 10000) / 100).toFixed(2))]
      }
    }
  },
  {
    title: '认购调整金额（元）',
    field: 'subscribeAdjustmentAmount',
    minWidth: 180,
    cell:{
      value:(info)=> info.subscribeAdjustmentAmount,
      text:{
        type: 'number',
      }
    }
  },
  {
    title: '认购净值',
    field: 'subscribeNetWorth',
    minWidth: 180,
    cell:{
      value:(info)=> info.subscribeNetWorth,
      text:{
        type: 'number',
        fixed: 0
      }
    }
  },
  {
    title: '认购净值金额（元）',
    field: 'subscribeNetWorthAmount',
    minWidth: 170,
    slots: {
      default: (params, h) => {
        return [h('div', _this.$tool.formatterMoney(params.row
          .subscribeNetWorthAmount))]
      }
    }
  },
  {
    title: '认购净值率（%）',
    field: 'subscribeNetWorthRate',
    minWidth: 150,
    slots: {
      default: (params, h) => {
        return [h('div', ((params.row.subscribeNetWorthRate * 10000) / 100).toFixed(
          2))]
      }
    }
  },
  {
    title: '未到访认购',
    field: 'notVisitedSubscribe',
    minWidth: 180,
    cell:{
      value:(info)=> info.notVisitedSubscribe,
      text:{
        type: 'number',
        fixed: 0
      }
    }
  },
  {
    title: '首访认购',
    field: 'fastVisitedSubscribe',
    minWidth: 180,
    cell:{
      value:(info)=> info.fastVisitedSubscribe,
      text:{
        type: 'number',
        fixed: 0
      }
    }
  },
  {
    title: '首访认购率（%）',
    field: 'fastVisitedSubscribeRate',
    minWidth: 150,
    slots: {
      default: (params, h) => {
        return [h('div', ((params.row.fastVisitedSubscribeRate * 10000) / 100)
          .toFixed(2))]
      }
    }
  },
  {
    title: '回笼几次认购',
    field: 'returnVisitedCountSubscribe',
    minWidth: 130,
    cell:{
      value:(info)=> info.returnVisitedCountSubscribe,
      text:{
        type: 'number',
      }
    }
  }],
}